﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using System.IO.IsolatedStorage;
using Confucius.utils;

namespace Confucius.pages
{
    public partial class Information : PhoneApplicationPage
    {
        public Information()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Page_Loaded);
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            string title = null;
            string text = null;
            string iconid = null;
            if (NavigationContext.QueryString.ContainsKey("title"))
                title = NavigationContext.QueryString["title"];
            if (NavigationContext.QueryString.ContainsKey("text"))
                text = NavigationContext.QueryString["text"];
            if (NavigationContext.QueryString.ContainsKey("iconid"))
                iconid = NavigationContext.QueryString["iconid"];
            if (title == null || text == null)
                return;
            PageTitle.Text = title;
            textBlock1.Text = text;
            string iconUri = null;
            if (IsolatedStorageSettings.ApplicationSettings.Contains(Constants.CURRENT_GAMEID))
            {
                string gameID = (string)IsolatedStorageSettings.ApplicationSettings[Constants.CURRENT_GAMEID];
                iconUri = "/Confucius;component/assets/gameFiles/" + gameID + "/" + iconid + ".png";
            }
            if (iconUri != null)
                image1.Source = new BitmapImage(new Uri(iconUri, UriKind.Relative));

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
        }
    }
}